package org.reos;

import org.reos.ReGenerator.ReGenerator;
import org.reos.ReParser.ConfigDataValidator;
import org.reos.ReParser.ISection;
import org.reos.ReParser.RTGenConfigReader;

import java.util.ArrayList;


public class ReGen {

	private static String[] expectedArgs = {
		"A path to an input file"
	};
	
	public static void main(String[] args) {
		if (args.length != expectedArgs.length) {
			System.out.println("There is wrong number of input arguments");
			System.out.println(expectedArgs.length + " argument(s) expected:");
			for (int i = 0; i < expectedArgs.length; i++) {
				System.out.println("\t - " + expectedArgs[i]);
			}
			return;
		}
		
		System.out.println("Using \"" + args[0] + "\" to generate output data");
        ArrayList<ISection> configData = new RTGenConfigReader().populateConfigFromFile(args[0]);
		if (configData != null) {
			System.out.println("The input file has been parsed");
            if (ConfigDataValidator.validateConfigData(configData)) {
                System.out.println("Data validation succeeded");
            } else {
                System.out.println("Data validation FAILED. Nothing will be generated");
            }
		} else {
			System.out.println("GENERATION FAILED. Could not generate output files due to the above errors");
		}

        ReGenerator reos_gen = new ReGenerator();
        reos_gen.FillData();
        reos_gen.Generate();

	}

}
